#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n;
string a , b;
void solve()
{
	int n; cin >>n;
	string a , b; cin >> a >> b;
	int res2 = 0, ans = 0;
	for( int i = 0 ; i < n ; i++ ) 
	{
	    if( b[i] == '0' && i & 1 ) ans++;
	    else if( b[i] == '0' ) res2++;
	}
    for( int i = 0 ; i < n ; i++ )
    {
        if( a[i] == '1' )
        {
            if( i & 1 )
            {
                if( res2 == 0 )
                {
                    puts("NO");
                    return;
                }
                res2--;
            }
            else
            {
                if( ans == 0 )
                {
                    puts("NO");
                    return;
                }
                ans--;
            }
        }
    }
	puts("YES");
}
int main()
{
    int t; cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}